﻿/***********************************************************
Copyright © 2015 Howyoung.
************************************************************
You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty.
************************************************************
您可以对所收受的本程序源代码，无论以何种媒介，复制与发布其完
整的复制物，然而您必须以显著及适当的方式在每一份复制物上发布
适当的著作权标示及无担保声明。
***********************************************************/
using System;
using System.Deployment.Application;
using System.Windows.Forms;

namespace MinecraftSavesBackup
{
    public partial class About : Form
    {
        public About()
        {
            InitializeComponent();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void About_Load(object sender, EventArgs e)
        {
            versionLabel.Text = Application.ProductVersion;
        }

        private void outstandingContributionbutton_Click(object sender, EventArgs e)
        {
            OutstandingContribution OutstandingContribution = new OutstandingContribution();
            OutstandingContribution.Show();
        }

        private void updateButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (Properties.Settings.Default.Updated)
                {
                    if (MessageBox.Show("更新已完成，新特性将在重新启动程序后生效，要帮您重新启动程序吗？", "更新已完成", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        Properties.Settings.Default.Updated = false;
                        Properties.Settings.Default.Save();
                        Application.Restart();
                        Application.ExitThread();
                    }
                }
                else
                {
                    if (ApplicationDeployment.CurrentDeployment.CheckForUpdate())
                    {
                        Update Update = new Update();
                        Update.Show();
                    }
                    else
                    {
                        MessageBox.Show("软件已是最新版本。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                HandlingErrors.ErrorMessage(ex, "请检查您的网络连接并重试。");
                HandlingErrors.Record(ex);
            }
        }
    }
}
